package chamster;

import java.util.HashMap;

import chamster.actions.ForewardAction;
import chamster.actions.GoFrontLeftAction;
import chamster.actions.GoFrontRightAction;
import chamster.actions.HamsterAction;
import chamster.actions.MoveLeftAction;
import chamster.actions.MoveRightAction;
import chamster.random.RandomStatelessActionMachine;
import chamster.random.StaticRandomMachine;

public class RandomHamster extends BaseHamster {

	private final RandomStatelessActionMachine<RandomHamster> decisionMaker;
	public RandomHamster(int forewardChance, int leftChance, int forewardLeftChance,
			int rightChance, int forewardRightChance, int backwardChance) {
		HashMap<HamsterAction<RandomHamster>, Integer> actions = 
				new HashMap<HamsterAction<RandomHamster>, Integer>();
		actions.put(new ForewardAction<RandomHamster>(), forewardChance);
		actions.put(new GoFrontLeftAction<RandomHamster>(), forewardLeftChance);
		actions.put(new GoFrontRightAction<RandomHamster>(), forewardRightChance);
		actions.put(new MoveLeftAction<RandomHamster>(), leftChance);
		actions.put(new MoveRightAction<RandomHamster>(), rightChance);
		actions.put(new TurnBackAction<RandomHamster>(), backwardChance);
		this.decisionMaker = new StaticRandomMachine<RandomHamster>(actions);
	}
	
	@Override
	public void life() throws Exception {
		while(super.chargeLeft(1)) {
			this.decisionMaker.decideAndExecute(this);
			if(super.canPickup()) {
				super.pickup();
			}
		}
		System.out.println("Accu empty");
		
	}

}
